package com.project.controller;

import com.project.bean.SpeakBean;
import com.project.bean.UserBean;
import com.project.service.ISpeakServIce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("speak")
public class SpeakController {
    @Autowired
    private ISpeakServIce service;

    @RequestMapping("add")
    public List<SpeakBean> add(String content, int productId, HttpServletRequest req){
        UserBean user = (UserBean) req.getSession().getAttribute("loginUser");
        SpeakBean speak = new SpeakBean(user.getId(),content,productId);
        List<SpeakBean> list = service.addSpeak(speak);
        return list;
    }

}
